package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.service.CxunameServiceljc;
import com.zr.service.TeacherServiceHyx;
import com.zr.serviceImpl.CxunameServiceImplljc;
import com.zr.serviceImpl.TeacherServiceImplHyx;

public class adminSelectTeacherControllerHyx extends HttpServlet{
	
		TeacherServiceHyx tService = new TeacherServiceImplHyx();
		@Override
		protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			doPost(req, resp);
		}
		@Override
		protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
			req.setCharacterEncoding("utf8");
			resp.setCharacterEncoding("utf8");
			PrintWriter pw = resp.getWriter();
			String tname = req.getParameter("tname");
			int tid =0;
			if(tname.matches("[0-9]+")){
			tid =Integer.parseInt(req.getParameter("tname"));
			}
			int count = tService.findTeacherByTname(tname,tid);
			if(count>0){//判断相同用户名个数是否大于0
				pw.write("1");
			}else{
				pw.write("0");
			}
			pw.flush();
			pw.close();
		}

}
